<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="用户名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="username">
              <a-input v-model="model.username" placeholder="请输入用户名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="day">
              <j-date placeholder="请选择时间" v-model="model.day"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="精品点消耗数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="boutiqueConsume">
              <a-input-number v-model="model.boutiqueConsume" placeholder="请输入精品点消耗数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="刷新点消耗数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="refreshConsume">
              <a-input-number v-model="model.refreshConsume" placeholder="请输入刷新点消耗数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="职位浏览量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="positionBrowse">
              <a-input-number v-model="model.positionBrowse" placeholder="请输入职位浏览量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="电话查看量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="phoneLook">
              <a-input-number v-model="model.phoneLook" placeholder="请输入电话查看量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="简历投递量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="resumeDeliver">
              <a-input-number v-model="model.resumeDeliver" placeholder="请输入简历投递量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="面试邀请数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interviewInvite">
              <a-input-number v-model="model.interviewInvite" placeholder="请输入面试邀请数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="打开简历数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="openResume">
              <a-input-number v-model="model.openResume" placeholder="请输入打开简历数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="简历点消耗数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="resumeConsume">
              <a-input-number v-model="model.resumeConsume" placeholder="请输入简历点消耗数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="精准消费金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="accurateMoney">
              <a-input-number v-model="model.accurateMoney" placeholder="请输入精准消费金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="置顶消费金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="topMoney">
              <a-input-number v-model="model.topMoney" placeholder="请输入置顶消费金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="优选投递消费金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="youxuanMoney">
              <a-input-number v-model="model.youxuanMoney" placeholder="请输入优选投递消费金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="头条消费金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="toutiaoMoney">
              <a-input-number v-model="model.toutiaoMoney" placeholder="请输入头条消费金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="黄金展位消费金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="goldMoney">
              <a-input-number v-model="model.goldMoney" placeholder="请输入黄金展位消费金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="付费帖浏览量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payBrowse">
              <a-input-number v-model="model.payBrowse" placeholder="请输入付费帖浏览量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="收到的招聘聊天会话数" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="recruitChat">
              <a-input-number v-model="model.recruitChat" placeholder="请输入收到的招聘聊天会话数" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="招聘聊天阅读率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="recruitReadRate">
              <a-input-number v-model="model.recruitReadRate" placeholder="请输入招聘聊天阅读率" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="招聘聊天回复率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="recruitReplyRate">
              <a-input-number v-model="model.recruitReplyRate" placeholder="请输入招聘聊天回复率" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remarks">
              <a-input v-model="model.remarks" placeholder="请输入备注"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'Emp_58PayForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/emp/emp_58Pay/add",
          edit: "/emp/emp_58Pay/edit",
          queryById: "/emp/emp_58Pay/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>